
package com.graphite.http;

import com.graphite.model.BaseRequest;
import com.graphite.model.BaseResponse;
import com.graphite.model.GraphiteMetric;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

/**
 * @projectName: collect-service
 * @packageName: com.graphite.client
 * @className: com.graphite.http-> FetchGraphite
 * @createDate: 2021-05-31 17:17
 * @author: ZhangSheng
 * @version: 1.0
 * @description: GraphiteClientTask 客户端访问graphite的线程包装类
 */
public interface FetchGraphite<K extends BaseRequest, V extends BaseResponse> {
    /**
     * 向graphite发送数据
     * @param host: 主机地址
     * @param port：端口
     * @param graphiteMetrics：数据集
     * @return
     * @throws Exception
     */
    boolean sendData(String host, int port, List<GraphiteMetric> graphiteMetrics) throws InterruptedException, ExecutionException, TimeoutException;

    /**
     * 向graphite获取数据
     * @param request 请求参数
     * @return List<V>
     */
    V fetchData(K request) throws IOException, URISyntaxException;
}
